import json
from pathlib import Path

from openai import OpenAI
import platform
import yaml




ALPHA_VANTAGE = "alpha-vantage"


def get_model(client):
    print(client.models.list())


def get_yml_key(name):
    system_name = str(platform.system())

    if system_name == "Windows":
        cfg_path = "C://temp/trade/cfg.yml"
    elif system_name == "Linux":
        cfg_path = "/tmp/trade/cfg.yml"
    else:
        raise Exception(f"unsupported system: {system_name}")


    with open(cfg_path, "r", encoding="utf-8") as f:
        data = yaml.safe_load(f)

    return data["llm"][name]




def get_json_key(name):

    key_file = Path(__file__).resolve().parent.parent / "secret" / "api-key.json"

    with open(key_file, "r", encoding="utf-8") as f:
        keys = json.load(f)

    alpha_vantage_key = keys.get(name)

    if alpha_vantage_key:
        return alpha_vantage_key
    else:
        return None


if __name__ == '__main__':
    print(get_json_key(ALPHA_VANTAGE))